package com.ie.controller.admin;

import com.ie.common.http.ResponseResult;
import com.ie.common.security.anno.AuthIgrone;
import com.ie.common.security.utils.MD5Util;
import com.ie.dto.PasswordDTO;
import com.ie.entity.AUserEntity;
import com.ie.sevice.admin.AUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@RestController
@RequestMapping("/api/admin")
public class AUserController {
    @Autowired
    private AUserService aUserService;
    @AuthIgrone
    @PostMapping("/login")
    public ResponseResult<Map<String,String>> login(@RequestBody AUserEntity aUserEntity){


        return aUserService.login(aUserEntity);
    }
    @AuthIgrone
    @PostMapping("/updatePassword")
    public ResponseResult<Object> updatePassword(@RequestBody PasswordDTO passwordDTO) {
        return aUserService.updatePassword(passwordDTO);
    }

    @AuthIgrone // 忽略认证，方便测试
    @GetMapping("/getHash/{password}")
    public String getHash(@PathVariable String password) {
        return MD5Util.MD5(password);
    }
}
